package day06;

public class MethodDemo2 {
    public static void main(String[] args) {
        double a = getNum();
        System.out.println(a);

        int b = minus(7, 3);
        System.out.println(b);
        int m = 5, n = 6;
        int c = minus(m, n);
        System.out.println(c);
        System.out.println("======================");


        int[] d = setArray(8, 100);
        System.out.println("数组的长度为:" + d.length);
        for (int i = 0; i < d.length; i++) {
            System.out.println(d[i]);
        }

        System.out.println("======================");
        int[] e = setArray(5, 20);
        System.out.println("第1个元素的值为:" + e[0]);
        for (int i = 0; i < e.length; i++) {
            System.out.println(e[i]);
        }
    }

    //无参有返回值
    public static double getNum() {
        return 6666.66;
    }

    //有参有返回值
    public static int minus(int num1, int num2) {
        int num = num1 - num2;
        return num;
    }

    //无参有返回值
    public static int[] setArray(int len, int max) {
        int[] arr = new int[len];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * (max + 1));
        }
        return arr;
    }
}